<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateUserCouponsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('user_coupons', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('user_id')->default('0')->comment('用户ID');
            $table->integer('coupon_id')->default('0')->comment('优惠券ID');
            $table->tinyInteger('mode')->default('0')->comment('类型:0=洗车优惠券,1=商品优惠券');
            $table->string('title')->default('')->comment('优惠券标题');
            $table->tinyInteger('range')->default('0')->comment('使用限制:0=全场通用,1=指定分类,2=指定服务');
            $table->decimal('full_price')->default('0.00')->comment('满足使用条件');
            $table->decimal('price')->default('0.00')->comment('优惠金额');
            $table->integer('shop_id')->default('0')->comment('门店ID');
            $table->integer('cid')->default('0')->comment('分类ID');
            $table->integer('good_id')->default('0')->comment('商品ID');
            $table->integer('service_id')->default('0')->comment('服务ID');
            $table->json('areas')->nullable()->comment('所属地区ID组,默认null表示全国地区显示');
            $table->date('start_time')->comment('开启日期');
            $table->date('end_time')->comment('结束日期');
            $table->tinyInteger('status')->default('0')->comment('状态:0=未使用,1=已使用');
            $table->dateTime('used_time')->nullable()->comment('使用时间');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('user_coupons');
    }
}
